import { savePropertyMetadata } from '@midwayjs/core';
import { BusinessType } from "@utils/enum";

export const OPERATION_META_KEY = 'operation:type'

// 不知道怎么优雅地封装这个装饰器，先用装饰器 + 守卫结合 来解决

interface logInfoType {
  title: string, // 操作日志标题
  businessType: number, // 操作类型，详见"@utils/enum"
}

export { BusinessType }

// 操作日志
export function Log(logInfo: logInfoType): MethodDecorator {
  return (target, propertyKey, descriptor) => {
    savePropertyMetadata(OPERATION_META_KEY, logInfo, target, propertyKey);
  };
}
